from time import sleep
import uiautomation
import pyautogui


class Feiyaowuchufang():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    feiyaowuchufang = his.TabControl(AutomationId='tabZhenliao', ClassName='TabControl').TabItemControl(Name='非药物处方',ClassName='TabItem')  # 非药物处方
    # 非药物处方
    xiangmumingcheng1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell",foundIndex=1)
    xiangmumingcheng1_1 = xiangmumingcheng1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 项目名称输入框

    xiangmumingcheng2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell", foundIndex=2)
    xiangmumingcheng2_1 = xiangmumingcheng2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 项目名称输入框

    xiangmumingcheng3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell", foundIndex=3)
    xiangmumingcheng3_1 = xiangmumingcheng3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 项目名称输入框

    xiangmumingcheng4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell", foundIndex=4)
    xiangmumingcheng4_1 = xiangmumingcheng4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 项目名称输入框

    xiangmumingcheng5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 0',ClassName="DataGridCell", foundIndex=5)
    xiangmumingcheng5_1 = xiangmumingcheng5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 项目名称输入框


#非药物处方
    #点击非药物处方
    def click_feiyaowuchufang_btn(self):
        self.feiyaowuchufang.Click()
        sleep(1)


    #第一排数据
    def choose_fywcf_xmmc1(self,xmmc1):
            self.xiangmumingcheng1.DoubleClick()
            self.xiangmumingcheng1_1.SendKeys(xmmc1)
            pyautogui.press('enter')
            sleep(1)

    def choose_fywcf_xmmc2(self,xmmc2):
            self.xiangmumingcheng2.DoubleClick()
            self.xiangmumingcheng2_1.SendKeys(xmmc2)
            pyautogui.press('enter')
            sleep(1)
    def choose_fywcf_xmmc3(self,xmmc3):
            self.xiangmumingcheng3.DoubleClick()
            self.xiangmumingcheng3_1.SendKeys(xmmc3)
            pyautogui.press('enter')
            sleep(1)
    def choose_fywcf_xmmc4(self,xmmc4):
            self.xiangmumingcheng4.DoubleClick()
            self.xiangmumingcheng4_1.SendKeys(xmmc4)
            pyautogui.press('enter')
            sleep(1)
    def choose_fywcf_xmmc5(self,xmmc5):
            self.xiangmumingcheng5.DoubleClick()
            self.xiangmumingcheng5_1.SendKeys(xmmc5)
            pyautogui.press('enter')
            sleep(1)
#  输入非药物处方
    def input_all(self,xmmc1,xmmc2,xmmc3,xmmc4,xmmc5):
            self.xiangmumingcheng1.DoubleClick()
            self.xiangmumingcheng1_1.SendKeys(xmmc1)
            pyautogui.press('enter')
            self.xiangmumingcheng2.DoubleClick()
            self.xiangmumingcheng2_1.SendKeys(xmmc2)
            pyautogui.press('enter')
            self.xiangmumingcheng3.DoubleClick()
            self.xiangmumingcheng3_1.SendKeys(xmmc3)
            pyautogui.press('enter')
            self.xiangmumingcheng4.DoubleClick()
            self.xiangmumingcheng4_1.SendKeys(xmmc4)
            pyautogui.press('enter')
            self.xiangmumingcheng5.DoubleClick()
            self.xiangmumingcheng5_1.SendKeys(xmmc5)
            pyautogui.press('enter')




